<?php
	include_once('/config/class.pdo.php');
	
	$pdo = new DB;	
	$pdo-> conexao();

$req = 'SELECT ibgeEstado, uf, estado 
		FROM estado 
		WHERE uf LIKE "%'.@$_GET['term'].'%" OR estado LIKE "%'.@$_GET['term'].'%"'; 
		
$query = $pdo->select($req);

$return_arr = array();

if(!empty($query)){
	foreach($query as $row) {
		$results['value'] = utf8_encode($row['uf']).' - '.utf8_encode($row['estado']);
		
		$results['ibgeEstado'] = $row['ibgeEstado'];
		$results['uf'] = utf8_encode($row['uf']);
		
		array_push($return_arr, $results);
	}
	} else {
		$results['value']  = 'NAO ENCONTRADO';
		array_push($return_arr, $results);
	}
echo json_encode($return_arr);
?>
